package com.utils;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;

import com.models.Shared;
import com.models.User;

public class DBTest {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		User eu = new User("Eu", "1234", "");
		User tu = new User("Tu", "5678", "");
		User ele = new User("Ele", "abcd", "");
		DB.save(eu, tu, ele);
		Shared f1 = new Shared("fTu", "\\", "\\", tu, eu);
		Shared f2 = new Shared("fEle", "\\", "\\", ele, eu);
		Shared f3 = new Shared("fEu", "\\", "\\", eu, tu);
		Shared f4 = new Shared("fEu", "\\", "\\", eu, ele);
		DB.save(f1, f2, f3, f4);
		System.out.println("salvo");
		//show users
		Session session = DB.getSession();
		Criteria query = session.createCriteria(User.class);
		List<User> res = (List<User>)query.list();
		System.out.println("\n");
		for (User user : res)
			System.out.println(user.toString());
	}

}
